home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1993 May / Info-Mac_II_May_1993.to_.sit / Info-Mac II (May 1993).toast / Unix / Info-mac-browser.txt < prev    next >
Internet Message Format  |  1993-03-27  |  2KB

  1. From: Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>
  2. Date: Thu, 11 Feb 93 11:58:59 -0800 
  3. Subject: Browsing digests for recent uploads 
  4.  
  5. I wrote this quick Unix program for browsing info-mac digests. I try to keep  
  6. up with the new uploads to sumex, but it's a tedious, repetitive process to  
  7. actually download the stuff I want. This C program scans a digest (or several)  
  8. in a file or files given on the command line for the [*] denoting an upload  
  9. notice, and prints out the description. Type y if you want to download it, and  
  10. it adds the path and name to a file called "download". Typing n just continues  
  11. to the next message, and q quits the program. I then rearrange the file in  
  12. emacs, inserting cd and get commands, and paste it into an ftp session.
  13.  
  14. Hope it's useful to someone! Remember, it was only a half-hour hack; feel free  
  15. to improve on it.
  16.  
  17. Compile with cc -o skim skim.c -lcurses -ltermcap
  18. or take out the curses stuff if you don't have it.
  19.  
  20. ---
  21. Craig Nevill-Manning,            e-mail: cgn@waikato.ac.nz
  22. Department of Computer Science,  phone:  +64 7 838 4021 (work)
  23. University of Waikato,                   +64 7 838 4232 (home)
  24. Private Bag 3105,                      
  25.  
  26. Hamilton,
  27. New Zealand.
  28.  
  29. skim.c follows:
  30.  
  31.  
  32. #include <stdio.h>
  33. #include <curses.h>
  34.  
  35. FILE *download;
  36.  
  37. main(argc, argv)
  38. int argc;
  39. char **argv;
  40. {
  41.   int i;
  42.  
  43.   initscr();
  44.   cbreak();
  45.   
  46.  
  47.   download = fopen("download", "a");
  48.  
  49.   for (i = 1; i < argc; i ++)
  50.     skim(argv[i]);
  51.  
  52.   nocbreak();
  53.   endwin();
  54. }
  55.  
  56. skim(filename)
  57. char *filename;
  58. {
  59.   FILE *f;
  60.   char s[1000], name[1000];
  61.   int ch, line;
  62.  
  63.   f = fopen(filename, "r");
  64.  
  65.   if (f) {
  66.     
  67.  
  68.     while (!feof(f)) {
  69.       do {
  70.     fgets(s, 1000, f);
  71.       } while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
  72.  
  73.       line = 0;
  74.  
  75.       name[0] = 0;
  76.  
  77.  
  78.       clear();
  79.       refresh();
  80.  
  81.       puts(filename);
  82.       while (!feof(f)) {
  83.     if (line ++ < LINES - 4)
  84.       printf("%s", s);
  85.     fgets(s, 1000, f);
  86.     if (strncmp(s, "[Archived as", 12) == 0) {
  87.       strcpy(name, &s[13]);
  88.       break;
  89.     }
  90.       }
  91.  
  92.       printf("%s", s);
  93.       
  94.  
  95.       if (name[0]) {
  96.     printf("Get this? (y/n)");
  97.  
  98.     do
  99.       ch = getchar();
  100.     while (ch != 'y' && ch != 'n' && ch != 'q');
  101.  
  102.     if (ch == 'y') {
  103.       int i;
  104.  
  105.       for (i = strlen(name); i > 0 && name[i] != ';'; i --)
  106.         ;
  107.       name[i] = 0;
  108.  
  109.       fprintf(download, "%s\n", name);
  110.     }
  111.     else if (ch == 'q') {
  112.       fclose(download);
  113.       nocbreak();
  114.       endwin();
  115.       exit(0);
  116.     }
  117.       }
  118.     }
  119.  
  120.     fclose(f);
  121.   }
  122. }
  123.  
  124.  
  125.  
  126.  
  127.